/*
 * ENUM Discoverer. ENUM Demonstration software, demonstrating the potential of ENUM.
 * 
 * Copyright (C) 2009 SIDN and ISOC.nl
 * 
 * This file is part of ENUM Discoverer.
 *
 * ENUM Discoverer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ENUM Discoverer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ENUM Discoverer.  If not, see <http://www.gnu.org/licenses/>.
 */

package nl.sidn.enumdiscoverer.contacts.dao;

import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;

import android.content.Context;

import nl.sidn.enumdiscoverer.contacts.ContactDetails;

/**
 * Handles the writing of contact data associated with a particular person to Contacts.
 * Data isn't necessarily written to Contacts immediately, but is guaranteed to be
 * written before close() returns.
 * @author	Grant Patterson (grant.patterson@catalyst.net.nz)
 */
public abstract class PersonDao {
	
	protected PersonDao() {}
	
	public abstract HashMap<Integer, String> getWebLinks();
	
	public abstract void setWebLinks(HashMap<Integer, String> links);

	public abstract long getId();
	
	public abstract ContactDetails getDetails();
	
	public abstract void addPhoneNumber(String number);
	
	public abstract void addPostalAddress(String address);
	
	public abstract String getPrimaryPostalAddress();
	
	public abstract void addOrganisation(String organisation);
	
	public abstract void setPublicKey(String key);

	public abstract String getPublicKey();

	public abstract void setSipAddress(String address);

	public abstract String getSIPAddress();
	
	/**
	 * Gets an InputStream that contains the contact photo
	 * @return An ImputStream containing the photo.
	 *         null if there is no photo
	 */
	public abstract InputStream getPhoto();
	
	public abstract void setPhoto(byte[] photoBytes);
	
	public abstract void addEmailAddress(String address);
	
	public abstract void addInstantMessagingUrl(String imUrl, int protocol);
	
	/**
	 * Sets the person's current location
	 * @param location The person's current coordinates
	 */
	public abstract void setLocation(Coords location);
	
	public abstract Coords getLocation();
	
	public abstract void setName(String name);
	
	public abstract void setDateOfBirth(Date birthday);
	
	public abstract Date getDateOfBirth();
	
	public abstract void setStatus(String status);
	
	public abstract String getStatus();
	
	public abstract void close();
	
	static PersonDao createDaoForContact(Context context, long personId) {
		return new Android16PersonDao(context, personId, true);
	}
	
	static PersonDao createDaoForNewContact(Context context, long personId) {
		return new Android16PersonDao(context, personId, false);
	}
}
